/* 
 *  Copyright (C) 2006 James Young
 * `gurumind(a)gmail.com
 * 
 */

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace IPDEditor
{
    [Serializable()]
    public class Editors
    {
        public Hashtable editors;

        public Editors()
        {
            editors = new Hashtable();
        }

        public void Add(Editor editor)
        {
            editors.Add(editor.databaseName, editor);
        }

        public Editor GetEditorForDatabase(string DatabaseName)
        {
            if (editors.Contains(DatabaseName))
                return (Editor)editors[DatabaseName];
            else
            {
                Editor editor = new Editor(DatabaseName);
                editors.Add(DatabaseName, editor);
                return editor;
            }
        }
    }

    [Serializable()]
    public class Editor
    {
        public string databaseName;

        public Hashtable fields;

        public Editor(string DatabaseName)
        {
            databaseName = DatabaseName;
            fields = new Hashtable();
        }

        public void Add(EditorField field)
        {
            fields.Add(field.number, field);
        }
    }

    [Serializable()]
    public class EditorField
    {
        public string name;
        public int number;
        public int dataType;
        public string editorName;

        public EditorField(int Number, int DataType)
        {
            number = Number;
            dataType = DataType;
            name = string.Format("Field_{0}", number);
        }
    }
}
